package com.ruoyi.web.controller.xcx;

import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.AHousing;
import com.ruoyi.system.domain.vo.AHousingBackXcxVO;
import com.ruoyi.system.domain.vo.AHousingGoodXcxVO;
import com.ruoyi.system.domain.vo.AHousingXcxVO;
import com.ruoyi.system.domain.vo.PageVO;
import com.ruoyi.system.service.IAHousingService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 房屋信息Controller
 *
 * @author gf
 * @date 2024-11-23
 */
@RestController
@RequestMapping("/xcx/aHousing")
public class XcxAHousing extends BaseController {
    @Autowired
    private IAHousingService aHousingService;

    /**
     * 查询列表
     * @param aHousing
     * @return
     */
    @GetMapping("/list")
    public TableDataInfo list(AHousingXcxVO aHousing) {
        startPage();
        List<AHousingBackXcxVO> list = aHousingService.selectAHousingXcxList(aHousing);
        return getDataTable(list);
    }

    /**
     * 获取详情
     * @param id
     * @return
     */
    @GetMapping(value = "/getInfo/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id) {
        return success(aHousingService.selectAHousingByXcxId(id));
    }
    /**
     * 增加数据
     * @return
     */
    @PostMapping(value = "/add")
    public AjaxResult add(@RequestBody AHousing aHousing) {
        return success(aHousingService.insertAHousingXcx(aHousing));
    }

    /**
     * 修改数据
     * @return
     */
    @PostMapping(value = "/update")
    public AjaxResult update(@RequestBody AHousing aHousing) {
        return toAjax(aHousingService.insertAHousingXcxEdit(aHousing));
    }

    /**
     * 删除数据
     * @param id
     * @return
     */
    @GetMapping("/remove/{id}")
    public AjaxResult remove(@PathVariable Long id) {
        return toAjax(aHousingService.deleteAHousingByXcxId(id));
    }

    /**
     * 当前用户统计数
     * @return
     */
    @GetMapping("/countHousing")
    public AjaxResult countHousing() {
        return success(aHousingService.selectAHousingCountHousing());
    }

    /***
     * 我的房源统计
     * @param
     * @return
     */
    @GetMapping("/myHousing")
    public TableDataInfo myHousing(PageVO vo) {
        startPage();
        List<AHousingBackXcxVO> list = aHousingService.selectAHousingMyHousing(vo);
        return getDataTable(list);
    }


    /**
     * 区 统计数
     * @param region
     * @return
     */
    @GetMapping("/countRegion/{region}")
    public AjaxResult countRegion(@PathVariable("region") String region) {
        return success(aHousingService.selectAHousingCountRegion(region));
    }

    /**
     * 区 相关的数据
     * @param
     * @return
     */
    @GetMapping("/myRegion")
    public TableDataInfo myRegion(AHousing aHousing) {
        startPage();
        List<AHousingBackXcxVO> list = aHousingService.selectAHousingMyRegion(aHousing);
        return getDataTable(list);
    }

    /**
     * 个人中心 点击修改返回数据
     * @param id
     * @return
     */
    @GetMapping(value = "/getXcxInfo/{id}")
    public AjaxResult getXcxInfo(@PathVariable("id") Long id) {
        return success(aHousingService.selectAHousingByGetXcxId(id));
    }

    /**
     * 更新访问量
     * @param id
     * @return
     */
    @GetMapping(value = "/updateVisit/{id}")
    public AjaxResult updateVisit(@PathVariable("id") Long id) {
        return success(aHousingService.selectAHousingByUpdateVisit(id));
    }
    /**
     * 更新曝光量
     * @param id
     * @return
     */
    @GetMapping(value = "/updateExposure/{id}")
    public AjaxResult updateExposure(@PathVariable("id") Long id) {
        return success(aHousingService.selectAHousingByUpdateExposure(id));
    }
    /**
     * 更新电话访问量
     * @param id
     * @return
     */
    @GetMapping(value = "/updatePhone/{id}")
    public AjaxResult updatePhone(@PathVariable("id") Long id) {
        return success(aHousingService.selectAHousingByUpdatePhone(id));
    }

    /**
     * 保存H5页面数据
     * @return
     */
    @PostMapping(value = "/hAdd")
    public AjaxResult hAdd(@RequestBody AHousing aHousing) {
        AjaxResult aj = new AjaxResult();
        aj.put("id",aHousingService.insertAHousingXcxHAdd(aHousing));
        return success(aj);
    }

    /**
     * 首页喜报滚动数据
     * @return
     */

    @GetMapping(value = "/goodList")
    public AjaxResult goodList(AHousing aHousing) {
        List<AHousingGoodXcxVO> list = aHousingService.selectAHousingXcxGoddList(aHousing);
        return success(list);
    }

}
